home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 23 / CU Amiga - Super CD-ROM 23 (June 1998).iso / CUCD / Sound / PreludeAMP / src / audio.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-01-25  |  4.3 KB  |  182 lines

  1. /* this file is a part of amp software, (C) tomislav uzelac 1996,1997
  2. */
  3.  
  4. /* audio.h  some global variables
  5.  *
  6.  * Created by: tomislav uzelac Mar/Apr, Jul 96
  7.  */
  8.  
  9. #include <stdio.h>
  10. #include <string.h>
  11.  
  12. struct AUDIO_HEADER {
  13.     int ID;
  14.     int layer;
  15.     int protection_bit;
  16.     int bitrate_index;
  17.     int sampling_frequency;
  18.     int padding_bit;
  19.     int private_bit;
  20.     int mode;
  21.     int mode_extension;
  22.     int copyright;
  23.     int original;
  24.     int emphasis;
  25. };
  26.  
  27. struct SIDE_INFO {
  28.     int main_data_begin;
  29.     int scfsi[2][4];
  30.     int part2_3_length[2][2];
  31.     int big_values[2][2];
  32.     int global_gain[2][2];
  33.     int scalefac_compress[2][2];
  34.     int window_switching_flag[2][2];
  35.     int block_type[2][2];
  36.     int mixed_block_flag[2][2];
  37.     int table_select[2][2][3];
  38.     int subblock_gain[2][2][3];
  39.     int region0_count[2][2];
  40.     int region1_count[2][2];
  41.     int preflag[2][2];
  42.     int scalefac_scale[2][2];
  43.     int count1table_select[2][2];
  44. };
  45.  
  46.  
  47. /* global stuff 
  48. */
  49.  
  50. extern FILE *in_file,*out_file;
  51.  
  52. extern void statusDisplay(struct AUDIO_HEADER *header, int frameNo);
  53. extern int decodeMPEG(void);
  54. extern void initialise_globals(void);
  55. extern void report_header_error(int err);
  56.  
  57. extern int scalefac_l[2][2][22];
  58. extern int scalefac_s[2][2][13][3];
  59. extern int t_b8_l[2][3][22];
  60. extern int t_b8_s[2][3][13];
  61. extern short t_bitrate[2][3][15];
  62.  
  63. extern int is[2][578];
  64. extern float xr[2][32][18];
  65.  
  66. extern int *t_l,*t_s;
  67. extern int nch;
  68. extern int t_sampling_frequency[2][3];
  69.  
  70. extern int A_QUIET,A_SHOW_CNT,A_FORMAT_WAVE,A_DUMP_BINARY;
  71. extern int A_WRITE_TO_AUDIO,A_WRITE_TO_FILE;
  72. extern short pcm_sample[64];
  73. extern int A_AUDIO_PLAY;
  74. extern int A_SET_VOLUME,A_SHOW_TIME;
  75. extern int A_MSG_STDOUT;
  76. extern int A_DOWNMIX;
  77.  
  78. /* GUI CONTROL STUFF */
  79. extern int GUI_PLAY;
  80. extern int GUI_PLAYING;
  81. extern int GUI_PAUSE;
  82. extern int GUI_PAUSED;
  83. extern int GUI_STOP;
  84. extern int GUI_STOPPED;
  85. extern int GUI_FD_TO_PLAY;
  86. extern int GUI_NEXT_FILE_READY;
  87.  
  88. /* GUI control stuff */
  89. extern int send_fd;
  90. extern int receive_fd;
  91.  
  92. extern int stop_flag;
  93. extern int quit_flag;
  94.  
  95. /* ...
  96. */
  97.  
  98. #ifdef AUDIO
  99.  
  100. FILE *in_file,*out_file;
  101.  
  102. int scalefac_l[2][2][22];
  103. int scalefac_s[2][2][13][3];
  104.  
  105. int is[2][578];
  106. float xr[2][32][18];
  107.  
  108. int *t_l,*t_s;
  109. int nch;
  110. int t_sampling_frequency[2][3] = {
  111. { 22050 , 24000 , 16000},
  112. { 44100 , 48000 , 32000}
  113. };
  114.  
  115. /* GUI control stuff */
  116. int send_fd;
  117. int receive_fd;
  118.  
  119. int stop_flag;
  120. int quit_flag;
  121.  
  122. int GUI_PLAY,GUI_PLAYING,GUI_STOP,GUI_STOPPED,GUI_PAUSE,GUI_PAUSED;
  123. int GUI_FD_TO_PLAY,GUI_NEXT_FILE_READY;
  124.  
  125. int A_QUIET,A_SHOW_CNT,A_FORMAT_WAVE,A_DUMP_BINARY;
  126. int A_WRITE_TO_FILE;
  127. int A_AUDIO_PLAY;
  128. int A_SET_VOLUME, A_SHOW_TIME;
  129. int A_MSG_STDOUT;
  130. int A_DOWNMIX;
  131.  
  132. short pcm_sample[64];
  133.  
  134. short t_bitrate[2][3][15] = {{
  135. {0,32,48,56,64,80,96,112,128,144,160,176,192,224,256},
  136. {0,8,16,24,32,40,48,56,64,80,96,112,128,144,160},
  137. {0,8,16,24,32,40,48,56,64,80,96,112,128,144,160}
  138. },{
  139. {0,32,64,96,128,160,192,224,256,288,320,352,384,416,448},
  140. {0,32,48,56,64,80,96,112,128,160,192,224,256,320,384},
  141. {0,32,40,48,56,64,80,96,112,128,160,192,224,256,320}
  142. }};
  143.  
  144. /* the last sfb is given implicitly on pg.28. of the standard. scalefactors 
  145.  * for that one are 0, pretab also 
  146.  */
  147. /* leftmost index denotes ID, so first three tables are for MPEG2 (header->ID==0)
  148.  * and the other three are for MPEG1 (header->ID==1)
  149.  */
  150. /* 22.05, 24, 16 */
  151. int t_b8_l[2][3][22]={{ /* table B.8b ISO/IEC 11172-3 */
  152. {5,11,17,23,29,35,43,53,65,79,95,115,139,167,199,237,283,335,395,463,521,575},
  153. {5,11,17,23,29,35,43,53,65,79,95,113,135,161,193,231,277,331,393,463,539,575},
  154. {5,11,17,23,29,35,43,53,65,79,95,115,139,167,199,237,283,335,395,463,521,575}
  155. },{
  156. {3,7,11,15,19,23,29,35,43,51,61,73,89,109,133,161,195,237,287,341,417,575},
  157. {3,7,11,15,19,23,29,35,41,49,59,71,87,105,127,155,189,229,275,329,383,575},
  158. {3,7,11,15,19,23,29,35,43,53,65,81,101,125,155,193,239,295,363,447,549,575}
  159. }};   
  160. int t_b8_s[2][3][13]={{ /* table B.8b ISO/IEC 11172-3 */
  161. {3,7,11,17,23,31,41,55,73,99,131,173,191},
  162. {3,7,11,17,25,35,47,61,79,103,135,179,191},
  163. {3,7,11,17,25,35,47,61,79,103,133,173,191}
  164. },{
  165. {3,7,11,15,21,29,39,51,65,83,105,135,191},
  166. {3,7,11,15,21,27,37,49,63,79,99,125,191},
  167. {3,7,11,15,21,29,41,57,77,103,137,179,191}
  168. }};
  169.  
  170. int  args(int argc,char **argv);
  171. void initialise_decoder(void);
  172. int decodeMPEG(void);
  173. void initialise_globals(void);
  174. void report_header_error(int err);
  175. int  setup_audio(struct AUDIO_HEADER *header);
  176. void close_audio(void);
  177. int ready_audio(void);
  178.  
  179. void play(char *inFileStr, char *outFileStr);
  180.  
  181. #endif /* AUDIO */
  182.